<?php   // $Id $ ?>
<?php
/*
Copyright (C) 2007-2008 Pierre Coustillas
Licensed under the terms of the GNU  General Public License:http://www.opensource.org/licenses/gpl-license.php
File Authors:Pierre Coustillas
*/

require_once("include/verif.php");
require_once("include/config/common.php");
require_once("include/utils.php");
require_once("include/headers.php");

function combo_align($defaut)
{

	echo "<option value='L' "; if ($defaut=='L') { echo "selected='selected'" ;};echo ">Gauche</option>";
	echo "<option value='C' "; if ($defaut=='C') { echo "selected='selected'" ;};echo ">Centre</option>";
	echo "<option value='R' "; if ($defaut=='R') { echo "selected='selected'" ;};echo ">Droite</option>";

}

function get_text_align($align)
{
	$retour="";
	if ($align=='L')
		$retour = "left";
	if ($align=='C')
		$retour = "center";
	if ($align=='R')
		$retour = "right";

return $retour;
}

function combo_size($defaut)
{
	for ($i=8;$i<=16;$i++)
	{
		echo "<option value='$i' ";
		if ($i==$defaut) { echo "selected='selected'"; }
		echo ">$i</option>";
	}
}



?>

<script language="javascript" src="javascripts/verifier_form.js" type="text/javascript"></script>
<script type="text/javascript">
	function verif_creer_bon()
	{
		if (verifier('formu','black','date','vide#date_','num_client','egale_a%0'))
		{
			document.formu.submit();
		} else {
			alert("<?php aff_lang('Une des valeurs saisie n\'est pas correct.\nMerci de corriger avant de poursuivre.') ?>")	
		}

	}
</script>

<table class="page" align="center">
	<tr>
		<td class="page" align="center">
			<?php
			require_once("include/head.php");
			?>
		</td>
	</tr>
	<tr>
		<td class="page" align="center">
			<?php
			if ($user_admin != "y") { 
				echo "<h1>$lang_admin_droit</h1>";
				exit;
			}

			if (isset($_GET['message']))
			{
				echo "<h1>" . $_GET['message'] . "</h1>";
			}
			?>
		
			<br/>
		
			<center>
			<form action="coordonnees_soc_update.php" method="post" name="frm_coord" >
			<table class="boiteaction" width="80%">
				<caption><?php aff_lang("Coordonées de votre société") ?> &nbsp;  &nbsp;  &nbsp; <?php bouton_aide("coord_soc") ?></caption>
				<tr><td colspan="3"><br/><hr/><br/></td></tr>
				<tr>
					<td colspan="3" class="submit">Entête des documents</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td class="submit"><center><?php echo get_lang("colonne") . " 1" ?></center></td>
					<td class="submit"><?php echo get_lang("colonne") . " 2" ?></td>
				</tr>

			<?php
			$sql = "SELECT * FROM ${tblpref}coordonnees";
			$result = mysql_query($sql) or die("Erreur SQL !<br/>$sql<br/>" . mysql_error());

			for ($ligne=1;$ligne<=7;$ligne++)
			{
				
			$sql_ligne=mysql_fetch_array($result);
	
			?>
				<tr>
					<td>Ligne <?php echo $ligne ?></td>
					<td>
						<input style="text-align:<?php echo get_text_align($sql_ligne['col1_align']) ?>" type="text" name="<?php echo $ligne ?>_col1_nom" value="<?php echo $sql_ligne['col1_nom'] ?>" />
						<select name="<?php echo $ligne ?>_col1_align"><?php combo_align($sql_ligne['col1_align']) ?></select>
						<select name="<?php echo $ligne ?>_col1_size"><?php combo_size($sql_ligne['col1_size']) ?></select>
					</td>

					<td>
						<input style="text-align:<?php echo get_text_align($sql_ligne['col2_align']) ?>" type="text" name="<?php echo $ligne ?>_col2_nom" value="<?php echo $sql_ligne['col2_nom'] ?>" />
						<select name="<?php echo $ligne ?>_col2_align"><?php combo_align($sql_ligne['col2_align']) ?></select>
						<select name="<?php echo $ligne ?>_col2_size"><?php combo_size($sql_ligne['col2_size']) ?></select>
					</td>
				</tr>


			<?php
			}
			?>

				<tr><td colspan="3"><br/><hr/><br/></td></tr>

				<tr>
					<td colspan="3" class="submit">Pieds des documents</td>
				</tr>

			<?php
			for ($ligne=8;$ligne<=10;$ligne++)
			{
			$sql_ligne=mysql_fetch_array($result); //la suite du $result précédent

			?>
				<tr>
					<td>Ligne <?php echo $ligne -7 ?></td>
					<td colspan="2">
						<input style="text-align:center" type="text" size="60" name="<?php echo $ligne ?>_col1_nom" value="<?php echo $sql_ligne['col1_nom'] ?>" />
					</td>
				</tr>


			<?php
			}
			?>

				<tr><td colspan="3"><br/><hr/><br/></td></tr>

				<tr>
					<td colspan="3">
						<center><input type="submit" value="  Mettre à jour vos coordonnées  " /></center>
					</td>
				</tr>

			</table>
			</form>
			</center>

		</td>
	</tr>
	<tr>
		<td>
			<?php
			require_once("include/bas.php");
			?>
		</td>
	</tr>

</table>
</body>
</html>
